$m(function (args) {
    var $this = $(this.element).closest("body");
    this.jobDialog = null;
    this.flowsParam = {};
    var that = this;
    flowInfo = {};
    var allDatas = [];
    flows = [];
    var allCount = 0;
    var rowDatas = {};
    //用于判断当前是在哪种筛选状态下
    var nowstatus = "";
    var successCount = 0;
    var failedCount = 0;
    //执行中的数据集
    var runningDatas = [];
    //未执行的数据集
    var unstartDatas = [];
    //启动中的数据集
    var startingDatas = [];
    //用于从服务详情页面点击返回，页面刷新后的行判断
    var flowIdandStatus = [];
    //定义一个判断用户是否点击筛选-查询的标识
    var isSearch = false;
    //定义一个存储点击筛选-查询时，筛选里所有框的信息
    var searchData = {};

    var showTip = function (text) {
        $("<div/>").alert({
            msg: text,
            title: TempoUtils.locale("mine.prompt")
        });
    }

    $this.find("#jobContainer").layout({
        north: {
            resizable: false,
            size: 100,
            spacing_open: 0
        },
        center: {
            onresize: TempoUtils.throttle(function () {
            }, 200, true)
        }
    });

    /**
     * 流服务列表点击事件
     */
    var flowClickEvent = function () {
        //为筛选按钮添加弹出框事件
        $this.find("#shaixuan").off('click').on('click', function (e) {
            var dialog = $("<div id='shaixuanDailog'></div>");
            //弹出列表进行编辑
            dialog.dialog({
                width: 300,
                height: 300,
                title: "筛选",
                modal: true,
                resizable: "no",
                open: function () {
                    $m.loadHtml(contextPath + "/api/ai/app/statistics/view/dialog", dialog);
                },
                buttons: []
            });
        });
        //为筛选框添加图标提示
        $(".sizer").blur(function () {
            //获取筛选div里的搜索input框
            var inputs = $('#shaixuanDiv').find('input');
            //定义是否有数据标识 true表示有数据
            var hasValue = false;
            for (var i = 0; i < inputs.length; i++) {
                if (inputs.eq(i).val().trim() != "") {
                    hasValue = true;
                    break;
                }
            }
            //如果搜索框中有值，则显示图标
            if (hasValue) {
                $("#ifshaixuan").removeAttr('style');
                $(".sizer-reset").css("color", "#5185e4")
            } else {
                $("#ifshaixuan").hide();
            }
        });
        //为重置按钮添加点击事件
        $(".sizer-reset").click(function () {
            //将搜索状态改为false，并清空筛选数据
            isSearch = false;
            searchData = {};
            $("#ifshaixuan").hide();
            //将日期选择器清除，并重新初始化
            $("input[name='laststarttime']").datepicker("destroy");
            $("input[name='lastendtime']").datepicker("destroy");
            $(".tempo-sizer-inputright input").val("");
            initRefresh(false);
            get_sizerdata(nowstatus);
        });
        var bt_starting = $(".tempo-task-starting");
        var bt_complete = $(".tempo-task-complete");
        var bt_unstart = $(".tempo-task-unstart");
        var bt_startsuc = $(".tempo-task-startSucceed");
        var changeBtColor = function (bt1, bt2, bt3) {
            bt1.css("color", "dimgray");
            bt1.css("background-color", "#eee");
            bt2.css("color", "dimgray");
            bt2.css("background-color", "#eee");
            bt3.css("color", "dimgray");
            bt3.css("background-color", "#eee");
        }
        //根据传入状态获取数据方法
        var getDatabyState = function (status) {
            that.grid.datagrid('reloadGrid', {status: status});
        }
        //为已启动按钮添加筛选事件
        $("#tempo-asyn-runningbt").off('click').on('click', function () {
            nowstatus = "isrunning";
            runningDatas = [];
            $(".after_select").hide();
            $(this).css("color", "#5185e4");
            $(this).css("background-color", "#dfe9fd");
            changeBtColor(bt_starting, bt_complete, bt_unstart);
            getDatabyState("running");
        });
        //为启动中按钮添加筛选事件
        $("#tempo-asyn-starting").off('click').on('click', function () {
            nowstatus = "starting";
            startingDatas = [];
            $(".after_select").hide();
            $(this).css("color", "#5185e4");
            $(this).css("background-color", "#dfe9fd");
            changeBtColor(bt_startsuc, bt_complete, bt_unstart);
            getDatabyState("starting");
        });
        //为未启动的按钮添加点击筛选条件
        $("#tempo-asyn-unrunbt").off('click').on('click', function () {
            nowstatus = "unstart";
            unstartDatas = [];
            $(".after_select").hide();
            $(this).css("color", "#5185e4");
            $(this).css("background-color", "#dfe9fd");
            changeBtColor(bt_startsuc, bt_complete, bt_starting);
            getDatabyState("unstart");
        });
        //为“全部”按钮绑定筛选条件
        $(".tempo-task-complete").off('click').on('click', function () {
            nowstatus = "all";
            $(".after_select").hide();
            $(this).css("color", "#5185e4");
            $(this).css("background-color", "#dfe9fd");
            changeBtColor(bt_startsuc, bt_unstart, bt_starting);
            getDatabyState("");
        });
        var get_sizerdata = function (statusParam) {
            var publishtime_pre = $("input[name='laststarttime']").datepicker('getDate');
            var publishtime_end = $("input[name='lastendtime']").datepicker('getDate');
            var sizerdata = {
                serverName: $("input[name='serveName']").val().trim(),
                workspaceName: $("input[name='workspaceName']").val().trim(),
                applicationName: $("input[name='applicationName']").val().trim(),
                jobcreator: $("input[name='jobcreator']").val().trim(),
                publishtime_pre: publishtime_pre ? DateUtils.formatDate(publishtime_pre, 'yyyy-MM-dd') : null,
                publishtime_end: publishtime_end ? DateUtils.formatDate(publishtime_end, 'yyyy-MM-dd') : null,
                status: statusParam
            };
            searchData = sizerdata;
            that.grid.datagrid("reloadGrid", sizerdata);
        }
        //筛选框查询事件
        $this.find(".tempo-sizer-btdiv .queryBtn").off('click').on('click', function () {
            $("#shaixuanDiv").hide();
            isSearch = true;
            get_sizerdata(nowstatus);
        });
        //取消发布点击
        $(".tempo-flow-unpublish").off('click').on('click', function (e) {
            var id = $(this).attr('serviceId');
            var flowObjectId = $(this).attr('flowObjectId');
            $('<div/>').confirm({
                msg: "是否确认取消发布？",
                ok: function () {
                    var progressbar = $("<div/>").tempoprogressbar();
                    $.ajax({
                        url: contextPath + "/api/ai/app/unpublish",
                        data: {
                            id: flowObjectId,
                            flowObjectId: id
                        },
                        dataType: 'json',
                        type: 'post',
                        traditional: true,
                        success: function (result) {
                            progressbar.tempoprogressbar("destroy");
                            if (result.success) {
                                nowSizerStatus();
                            } else {
                                TempoUtils.showTip(result.message);
                            }
                        },
                        error: function (e) {
                            progressbar.tempoprogressbar("destroy");
                            nowSizerStatus();
                        }
                    });
                }
            });
        });
        //单个启动点击事件
        $(".tempo-start-service").off('click').on('click', function (e) {
            var serviceId = $(this).attr('serviceId');
            $('<div/>').confirm({
                msg: "是否确认启动？",
                ok: function () {
                    var progressbar = $("<div/>").tempoprogressbar();
                    $.ajax({
                        url: contextPath + "/api/ai/mine/stream/batch-start",
                        data: {
                            serviceIdList: [serviceId].join(","),
                        },
                        dataType: 'json',
                        type: 'post',
                        traditional: true,
                        success: function (result) {
                            //接口返回增加启动禁用样式
                            $(this).css("color", "gray").css("cursor", "pointer").css("pointer-events", "none");
                            progressbar.tempoprogressbar("destroy");
                            if (result.success) {
                                nowSizerStatus();
                            } else {
                                TempoUtils.showTip(result.message);
                            }
                        },
                        error: function (e) {
                            progressbar.tempoprogressbar("destroy");
                            nowSizerStatus();
                        }
                    });
                }
            });
        })
        //单个停止点击事件
        $(".tempo-stop-service").off('click').on('click', function (e) {
            var serviceId = $(this).attr('serviceId');
            $('<div/>').confirm({
                msg: "是否确认停止？",
                ok: function () {
                    var progressbar = $("<div/>").tempoprogressbar();
                    $.ajax({
                        url: contextPath + "/api/ai/mine/stream/batch-stop",
                        data: {
                            serviceIdList: [serviceId].join(","),
                        },
                        dataType: 'json',
                        type: 'post',
                        traditional: true,
                        success: function (result) {
                            //接口返回增加停止禁用样式
                            $(this).css("color", "gray").css("cursor", "pointer").css("pointer-events", "none");
                            progressbar.tempoprogressbar("destroy");
                            if (result.success) {
                                nowSizerStatus();
                            } else {
                                TempoUtils.showTip(result.message);
                            }
                        },
                        error: function (e) {
                            progressbar.tempoprogressbar("destroy");
                            nowSizerStatus();
                        }
                    });
                }
            });
        })
        //批量取消发布点击事件
        $(".tempo-batch-unpublish").off('click').on('click', function (e) {
            var allselectDatas = that.grid.datagrid("getSelectRowData");
            var size = allselectDatas.length;
            if (size == 0) {
                showTip("服务列表为空！");
                return;
            }
            var idList = [];
            var flowObjectIdList = [];
            for (var i = 0; i < size; i++) {
                //之前id传入有误，导致传入后台接口查询parentId为空
                idList.push(allselectDatas[i].SERVICEFLOWID);
                flowObjectIdList.push(allselectDatas[i].SERVICEID);
            }
            $("<div>").confirm({
                width: 500,
                height: 197,
                msg: "已选中" + size + "个任务，是否确定批量取消发布？",
                ok: function () {
                    var process = $("<div/>").tempoprogressbar();
                    $(".after_select").hide();
                    $.ajax({
                        url: contextPath + '/api/ai/app/batch-unpublish',
                        type: 'post',
                        traditional: true,
                        data: {
                            id: idList,
                            flowObjectId: flowObjectIdList
                        },
                        success: function (rs) {
                            if (rs.success) {
                                process.tempoprogressbar("destroy");
                                $this.find('.cglist-view-container').empty();
                                $m.loadPage(contextPath + "/api/ai/app/schedule/view/flow_server", $this.find('.cglist-view-container'));
                                nowSizerStatus();
                            } else {
                                process.tempoprogressbar("destroy");
                                nowSizerStatus();
                                TempoUtils.showTip("服务为已启动状态，不允许取消发布");
                            }
                        },
                        error: function (e) {
                            process.tempoprogressbar("destroy");
                            nowSizerStatus();
                        }
                    });
                }
            });
        })
        //批量启动点击事件
        $(".tempo-batch-start-service").off('click').on('click', function (e) {
            var allselectDatas = that.grid.datagrid("getSelectRowData");
            var size = allselectDatas.length;
            if (size == 0) {
                showTip("服务列表为空！");
                return;
            }
            var serviceIdList = [];
            for (var i = 0; i < size; i++) {
                serviceIdList.push(allselectDatas[i].SERVICEID);
            }
            $("<div>").confirm({
                width: 500,
                height: 197,
                msg: "已选中" + size + "个任务，是否确定批量启动？",
                ok: function () {
                    var progressbar = $("<div/>").tempoprogressbar();
                    $.ajax({
                        url: contextPath + "/api/ai/mine/stream/batch-start",
                        data: {
                            serviceIdList: serviceIdList.join(","),
                        },
                        dataType: 'json',
                        type: 'post',
                        traditional: true,
                        success: function (result) {
                            for (var i = 0; i < serviceIdList.length; i++) {
                                //获取到对应的启动按钮
                                var button = that.grid.find("a[serviceid=" + serviceIdList[i] + "].tempo-start-service");
                                //将停止按钮禁用
                                button.css("color", "gray").css("cursor", "pointer").css("pointer-events", "none");
                            }
                            progressbar.tempoprogressbar("destroy");
                            if (result.success) {
                                nowSizerStatus();
                            } else {
                                TempoUtils.showTip(result.message);
                            }
                        },
                        error: function (e) {
                            progressbar.tempoprogressbar("destroy");
                            nowSizerStatus();
                        }
                    });
                }
            });
        })
        //批量停止点击事件
        $(".tempo-batch-stop-service").off('click').on('click', function (e) {
            var allselectDatas = that.grid.datagrid("getSelectRowData");
            var size = allselectDatas.length;
            if (size == 0) {
                showTip("服务列表为空！");
                return;
            }
            var serviceIdList = [];
            for (var i = 0; i < size; i++) {
                serviceIdList.push(allselectDatas[i].SERVICEID);
            }
            $("<div>").confirm({
                width: 500,
                height: 197,
                msg: "已选中" + size + "个任务，是否确定批量停止？",
                ok: function () {
                    var progressbar = $("<div/>").tempoprogressbar();
                    $.ajax({
                        url: contextPath + "/api/ai/mine/stream/batch-stop",
                        data: {
                            serviceIdList: serviceIdList.join(","),
                        },
                        dataType: 'json',
                        type: 'post',
                        traditional: true,
                        success: function (result) {
                            for (var i = 0; i < serviceIdList.length; i++) {
                                //获取到对应的停止按钮
                                var button = that.grid.find("a[serviceid=" + serviceIdList[i] + "].tempo-stop-service");
                                //将停止按钮禁用
                                button.css("color", "gray").css("cursor", "pointer").css("pointer-events", "none");
                            }
                            progressbar.tempoprogressbar("destroy");
                            if (result.success) {
                                nowSizerStatus();
                            } else {
                                TempoUtils.showTip(result.message);
                            }
                        },
                        error: function (e) {
                            progressbar.tempoprogressbar("destroy");
                            nowSizerStatus();
                        }
                    });
                }
            });
        })
    }

    var DataObserveCenter = (function () {
        var manualArray = {};
        var stopArray = {};
        return {
            manualJob: function (id) {
                manualArray[id] = true;
            },
            isObserve: function (id) {
                return !!manualArray[id];
            },
            remove: function (id) {
                if (manualArray[id])
                    delete manualArray[id];
                if (stopArray[id])
                    delete stopArray[id];
            },
            isStop: function (id) {
                return !!stopArray[id];
            },
            stopJob: function (id) {
                stopArray[id] = true;
            }
        }
    })();

    /**
     * 判断当前选中的是在哪种筛选状态下
     */
    var nowSizerStatus = function () {
        if (nowstatus == 'isrunning') {
            $("#tempo-asyn-runningbt").trigger('click');
        } else if (nowstatus == 'starting') {
            $("#tempo-task-starting").trigger('click');
        } else if (nowstatus == 'unstart') {
            $("#tempo-asyn-unrunbt").trigger('click');
        } else {
            $("#tempo-asyn-allbt").trigger('click');
        }
    }

    /**
     * 列表事件
     */
    var bindJobGridEvent = function () {
        var grid = $this.find('#mine-opt-job-grid');
        //点击服务名称，跳转任务详情界面
        grid.find('.tempo-datagrid-trigger-name').off('click').on("click", function (e) {
            var rowid = $(e.target).attr('rowid');
            var flowid = $(e.target).attr('flowId');
            var row = rowDatas[flowid];
            flowIdandStatus = [];
            var oldStatus = row.LAUNCH_STATE;
            flowIdandStatus.push(flowid);
            flowIdandStatus.push(oldStatus);
            td = $(e.target).attr('rowid');
            viewDetail(row);
        })

        var asyncEnableOrDisabled = function (serviceId, flag) {
            $.ajax({
                url: contextPath + '/api/ai/mine/publish/async-enable',
                type: 'post',
                data: {
                    id: serviceId,
                    flag: flag
                },
            })
            that.grid.jqGrid().trigger("reloadGrid");
        }
    }

    var viewDetail = function (job) {
        openViewDetailDialog(job);
    }

    var sizerDivShow = function (one) {
        $("#shaixuanDiv").slideToggle();
        $(".tempo-sizer-icon").toggleClass("ui-icon tempo-ui-icon tempo-ui-icon-downarrows-thin");
        $(".tempo-sizer-icon").toggleClass("ui-icon tempo-ui-icon tempo-ui-icon-uparrows-thin");
        $(document).bind("click", function (e) {
            var target = $(e.target);
            if (target.closest(one).length == 0) {
                $("#shaixuanDiv").hide();
                $(".tempo-sizer-icon").toggleClass("ui-icon tempo-ui-icon tempo-ui-icon-uparrows-thin");
                $(".tempo-sizer-icon").toggleClass("ui-icon tempo-ui-icon tempo-ui-icon-downarrows-thin");
                $(document).off('click');
            }
        });
    }

    //筛选框弹出事件绑定
    $("#shaix").click(function () {
        sizerDivShow("#shaixuanDiv,#shaix,.tempo-sizer-icon,.ui-datepicker-title,.ui-datepicker-current,.mark,.ui-datepicker-close,.ui-datepicker-calendar,#ui-datepicker-div,.ui-datepicker-prev,.ui-datepicker-next");
    });

    //筛选图标点击事件
    $(".tempo-sizer-icon").click(function () {
        sizerDivShow("#shaixuanDiv,#shaix,.tempo-sizer-icon,.ui-datepicker-title,.ui-datepicker-current,.mark,.ui-datepicker-close,.ui-datepicker-calendar,#ui-datepicker-div,.ui-datepicker-prev,.ui-datepicker-next");
    });

    //当成功失败次数太多时显示不下，因此根据数量扩展外层div大小
    var extendDiv = function (num, object) {
        var oldWidth = object.width();
        if (num >= 100000 && num < 1000000) {
            object.css("width", oldWidth + 20);
        } else if (num >= 1000000) {
            object.css("width", oldWidth + 40);
        }
    }

    /**
     * 初始化列表
     */
    var initJobGrid = function () {
        $this.find('#gbox_mine-opt-job-grid').find(".ui-jqgrid-htable ").css("width", "100%");
        that.grid = $this.find('#mine-opt-job-grid').datagrid({
            datatype: "json",
            url: contextPath + '/api/ai/mine/publish/flow-data-job',
            postData: {},
            fit: true,
            autowidth: true,
            mtype: 'POST',
            rownumbers: true,
            shrinkToFit: true,
            viewrecords: true,
            //是否开启刷新按钮
            showRefreshBth: true,
            pagination: true,
            striped: true,
            multiselect: true,
            loadui: 'disable',
            //勾选后的触发事件
            onSelectRow: function (rowids, status) {
                var multiselect = that.grid.jqGrid().getGridParam("multiselect");
                var seleccount = that.grid.datagrid("getSelectRowIds").length;
                $(".tempo-datagrid-trigger-name").css("color", "black");
                if (multiselect && status) {
                    $(".selectedSpan").text("已选择 " + seleccount + " 条");
                    $this.find(".after_select").show();
                } else {
                    $(".selectedSpan").text("已选择 " + seleccount + " 条");
                }
                if (seleccount == 0) {
                    $this.find(".after_select").hide();
                }
                //全选按钮是否选中
                if (that.grid.find("input").length == seleccount) {
                    that.grid.parent().parent().parent().find("input[id$='_mine-opt-job-grid']").prop("checked", true);
                }
            },
            onSelectAll: function (rowids, status) {
                var multiselect = that.grid.jqGrid().getGridParam("multiselect");
                var seleccount = that.grid.datagrid("getSelectRowIds").length;
                $(".selectedSpan").text("已选择 " + seleccount + " 条");
                if (multiselect && status) {
                    that.grid.jqGrid()
                    $this.find(".after_select").show();
                } else {
                    $this.find(".after_select").hide();
                }
                //勾选全部批量取消分享成果
                $('.tempo-batchDeleteCategory').off('click').on("click", function (e) {
                    var allselectDatas = that.grid.datagrid("getSelectRowData");
                    var rowIds = that.grid.datagrid("getSelectRowIds");
                    var categoryidList = [];
                    for (var i = 0; i < rowIds.length; i++) {
                        categoryidList.push(allselectDatas[i].CATEGORYID);
                    }

                    $("<div>").confirm({
                        width: 500,
                        height: 197,
                        msg: "已选中" + rowIds.length + "个任务，是否确定批量取消分享？",
                        ok: function () {
                            var process = $("<div/>").tempoprogressbar();
                            $(".after_select").hide();
                            $.ajax({
                                url: contextPath + '/api/ai/app/category/batchDelete',
                                type: 'post',
                                data: {
                                    ids: categoryidList.toString(),
                                    type: 'warehouse'
                                },
                                success: function (obj) {
                                    process.tempoprogressbar("destroy");
                                    $this.find(".after_select").hide();
                                    $this.find('.cglist-view-container').empty();
                                    $m.loadPage(contextPath + "/api/ai/app/schedule/view/flow_server", $this.find('.cglist-view-container'));
                                    nowSizerStatus();
                                }, error: function (obj) {
                                    process.tempoprogressbar("destroy");
                                    that.grid.jqGrid().trigger("reloadGrid");
                                }
                            });
                        }
                    });
                });
            },
            colNames: ['id',
                'serviceFlowId',
                'jobId',
                'categoryId',
                'serviceId',
                'resourceId',
                '服务名称',
                '所属空间',
                '所属应用',
                '发布人',
                '发布时间',
                //上一次执行耗时
                TempoUtils.locale("mine.publish-mine-job-grid-col-lastcosttime"),
                '服务状态',
                TempoUtils.locale("mine.zhixingqingkuang"),
                //操作
                TempoUtils.locale("mine.publish-mine-job-grid-col-opt")
            ],
            colModel: [{
                name: 'id',
                hidden: true
            }, {
                name: 'SERVICEFLOWID',
                hidden: true,
                width: 8
            },{
                name: 'jobid',
                hidden: true
            }, {
                name: "CATEGORYID",
                hidden: true,

            }, {
                name: "SERVICEID",
                hidden: true
            }, {
                name: "RESOURCEID",
                hidden: true
            }, {
                name: 'SERVENAME',
                hidden: false,
                sortable: false,
                formatter: function (obj, rows, grid) {
                    rowDatas[grid.CATEGORYID] = grid;
                    var html = "<a href='javascript:void(0);' class='tempo-datagrid-trigger-name' style='text-decoration: none;color: #333333'   rowid='" + rows.rowId + "'flowId='" + grid.FLOWID + "'>" + TempoMineUtils.encodeHTML(obj) + "</a>";
                    return html;
                }
            }, {
                //所属空间
                name: 'WORKSPACENAME',
                hidden: false,
                sortable: false,
                formatter: function (obj, rows, grid) {
                    if (obj == null) {
                        return "";
                    }
                    return obj.replace(/</g, "&lt;").replace(/>/g, '&gt;');
                }
            }, {
                //所属应用
                name: 'APPLICATION',
                hidden: false,
                sortable: false,
                formatter: function (obj, rows, grid) {
                    return obj.replace(/</g, "&lt;").replace(/>/g, '&gt;');
                }
            }, {
                //发布人
                name: 'CREATOR',
                sortable: false,
                sortable: false
            }, {
                //发布时间
                name: 'CREATETIME',
                hidden: false,
                sortable: true,
                align: "center",
                formatter: function (obj) {
                    if (obj) {
                        return DateUtils.formatDate(new Date(obj), "yyyy-MM-dd HH:mm:ss");
                    }
                    return;
                }
            }, {
                //上次执行耗时
                name: 'SPENDTIME',
                align: 'center',
                resizable: false,
                sortable: false,
            }, {
                //执行状态
                name: 'LAUNCH_STATE',
                index: 'LAUNCH_STATE',
                hidden: false,
                sortable: false,
                formatter: function (obj, grid, rows) {
                    var rowid = rows.SERVICEID;
                    var service_status = rowDatas[rowid].LAUNCH_STATE;
                    if (service_status == 'RUNNING') {
                        return '<span class="running" style="color:rgba(0, 148, 240, 1) ">已启动</span>';
                    } else if (service_status == 'STARTING') {
                        return '<span class="starting" style="color:rgba(0, 148, 240, 1) ">启动中</span>';
                    } else if (service_status == 'STOPPING') {
                        return '<span class="stopping" style="color:rgba(0, 148, 240, 1) ">停止中</span>';
                    } else {
                        return '<span class="unrunning" style="color: dimgrey">未启动</span>';
                    }
                }
            }, {
                name: 'CTYPE',
                index: 'CTYPE',
                sortable: false,
                title: false,
                formatter: function (obj, grid, rows) {
                    var success = rows.successCount || 0;
                    var fail = rows.failedCount || 0;
                    var successNum = success > 100 ? success.toString().substr(0, 2) + "." : success;
                    var failNum = fail > 100 ? fail.toString().substr(0, 2) + "." : fail;
                    return "<button class='state_succ_bt' title='成功" + success + "' " + "style='width: 50px;height: 20px;color:#5185e4;background-color: white;border:1px solid #5185e4;border-radius: 15px;'>" + "成功" + successNum + "</button>" +
                        "<button class='state_fail_bt' title='失败" + fail + "' style='width: 50px;height: 20px;color:#fc7f7f;background-color: white;border:1px solid #fc7f7f;border-radius: 15px;margin-left: 5px;'>" + "失败" + failNum + "</button>";
                }
            }, {
                name: 'rows',
                index: 'rows',
                sortable: false,
                formatter: function (obj, row, grid) {
                    var serviceId = grid.SERVICEID;
                    //之前id传入有误，导致传入后台接口查询parentId为空
                    var flowObjectId = grid.SERVICEFLOWID;
                    var service_status = rowDatas[serviceId].LAUNCH_STATE;
                    //单个启动或停止按钮
                    var btn;
                    if (service_status == 'RUNNING') {
                        //已启动（显示停止可点击）
                        btn = "<span><a class='tempo-stop-service' href='javascript:void(0)' " +
                            "style='line-height: 30px;color: #2E90E3;text-decoration: none' title='停止' " +
                            "serviceId='" + serviceId + "' flowObjectId='" + flowObjectId + "'>" + "停止" + "</a></span>";
                    } else if (service_status == 'STARTING') {
                        //启动中（显示启动置灰不可点击）
                        btn = "<span><a class='tempo-start-service' href='javascript:void(0)' " +
                            "style='line-height: 30px;color: gray;text-decoration: none;cursor: pointer;pointer-events: none' title='启动' " +
                            "serviceId='" + serviceId + "' flowObjectId='" + flowObjectId + "'>" + "启动" + "</a></span>";
                    } else if (service_status == 'STOPPING') {
                        //停止中（显示停止置灰不可点击）
                        btn = "<span><a class='tempo-stop-service' href='javascript:void(0)' " +
                            "style='line-height: 30px;color: gray;text-decoration: none;cursor: pointer;pointer-events: none' title='停止' " +
                            "serviceId='" + serviceId + "' flowObjectId='" + flowObjectId + "'>" + "停止" + "</a></span>";
                    } else {
                        //未启动（显示启动可点击）
                        btn = "<span><a class='tempo-start-service' href='javascript:void(0)' " +
                            "style='line-height: 30px;color: #2E90E3;text-decoration: none' title='启动' " +
                            "serviceId='" + serviceId + "' flowObjectId='" + flowObjectId + "'>" + "启动" + "</a></span>";
                    }
                    var unPublishBtn = "<span style='margin-left: 10px'><a class='tempo-do tempo-flow-unpublish' href='javascript:void(0)' " +
                        "style='line-height: 30px;color: #2E90E3;text-decoration: none' title='取消发布' " +
                        "serviceId='" + serviceId + "' flowObjectId='" + flowObjectId + "'>" + "取消发布" + "</a></span>";
                    return btn + unPublishBtn;
                }
            }
            ],
            loadComplete: function (datas) {
                $this.find(".tempo-sizer-icon").removeClass("ui-icon tempo-ui-icon tempo-ui-icon-uparrows-thin");
                $this.find(".tempo-sizer-icon").addClass("ui-icon tempo-ui-icon tempo-ui-icon-downarrows-thin");
                $this.find('#gbox_mine-opt-job-grid').find(".ui-state-default").css("padding-left", "0px");
                $this.find('#gbox_mine-opt-job-grid').find(".ui-state-default").css("padding-right", "0px");
                $this.find('#gbox_mine-opt-job-grid').find(".ui-jqgrid-htable ").css("width", "100%");
                $(".after_select").hide();
                var startSucCount = 0;
                var startFailcount = 0;
                var runningSucCount = 0;
                var runningFailCount = 0;
                var stopSucCout = 0;
                var stopFailCount = 0;
                var rows = datas.rows;
                var allSuccCount = 0;
                var allFailCount = 0;
                //当前点击服务名称的flowId
                var flowid = flowIdandStatus[0];
                $("#load_mine-opt-job-grid").hide();
                var searchDataTmp;
                if (isSearch) {
                    searchDataTmp = searchData;
                    searchDataTmp.status = "";
                    searchDataTmp.sidx = "";
                    searchDataTmp.sord = "";
                } else {
                    searchDataTmp = {
                        serverName: "",
                        workspaceName: "",
                        applicationName: "",
                        jobcreator: "",
                        publishtime_pre: null,
                        publishtime_end: null,
                        status: "",
                        sidx: "",
                        sord: "",
                    };
                }
                $.ajax({
                    url: contextPath + "/api/ai/mine/publish/flow-data-job",
                    type: 'post',
                    data: searchDataTmp,
                    success: function (results) {
                        allDatas = results.rows;
                        var resdata = results.rows;
                        var newData = [];
                        if (resdata.length == 0) {

                        }
                        for (i = 0; i < allDatas.length; i++) {
                            if (allDatas[i].LAUNCH_STATE == "RUNNING") {
                                if (allDatas[i].successCount != undefined) {
                                    runningSucCount += allDatas[i].successCount;
                                    runningFailCount += allDatas[i].failedCount;
                                    newData.push(allDatas[i]);
                                } else {
                                    runningSucCount += 0;
                                    runningFailCount == 0;
                                }
                            } else if (allDatas[i].LAUNCH_STATE == "STARTING") {
                                if (allDatas[i].successCount != undefined) {
                                    startSucCount += allDatas[i].successCount;
                                    startFailcount += allDatas[i].failedCount;
                                    newData.push(allDatas[i]);
                                } else {
                                    startSucCount += 0;
                                    startFailcount == 0;
                                }
                            } else {
                                if (allDatas[i].successCount != undefined) {
                                    stopSucCout += allDatas[i].successCount;
                                    stopFailCount += allDatas[i].failedCount;
                                    newData.push(allDatas[i]);
                                } else {
                                    stopSucCout += 0;
                                    stopFailCount == 0;
                                }
                            }
                        }
                        allSuccCount = stopSucCout + startSucCount + runningSucCount;
                        allFailCount = stopFailCount + startFailcount + runningFailCount;
                        if ("isrunning" == nowstatus) {
                            $(".tempo-task-succeed").val("成功" + runningSucCount);
                            $(".tempo-task-failed").val("失败" + runningFailCount);
                            extendDiv(runningSucCount, $(".tempo-task-succeed"));
                            extendDiv(runningFailCount, $(".tempo-task-failed"));
                        } else if ("starting" == nowstatus) {
                            $(".tempo-task-succeed").val("成功" + startSucCount);
                            $(".tempo-task-failed").val("失败" + startFailcount);
                            extendDiv(startSucCount, $(".tempo-task-succeed"));
                            extendDiv(startFailcount, $(".tempo-task-failed"));
                        } else if ("unstart" == nowstatus) {
                            $(".tempo-task-succeed").val("成功" + stopSucCout);
                            $(".tempo-task-failed").val("失败" + stopFailCount);
                            extendDiv(stopSucCout, $(".tempo-task-succeed"));
                            extendDiv(stopFailCount, $(".tempo-task-failed"));
                        } else {
                            $(".tempo-task-succeed").val("成功" + allSuccCount);
                            $(".tempo-task-failed").val("失败" + allFailCount);
                            extendDiv(allSuccCount, $(".tempo-task-succeed"));
                            extendDiv(allFailCount, $(".tempo-task-failed"));
                        }
                        $("#jqgh_mine-opt-job-grid_cb").css("padding-left", "12px");
                        $("#jqgh_mine-opt-job-grid_cb").parent().css("width", "35px");
                        $(this).data('rows', rows);
                        updatestaticsInfo(resdata);
                        bindJobGridEvent.apply(that);
                        flowClickEvent();
                        var arr = rows.filter(function (e) {
                            if ((DataObserveCenter.isObserve(e.id) && e.result != -1)
                                || (DataObserveCenter.isStop(e.id) && e.result == -1)) {
                                return true;
                            } else {
                                DataObserveCenter.remove(e.id);
                                return false;
                            }
                        });
                        //这里新new了一个newRows是为了处理安全问题Dynamic Code Evaluation: Code Injection；下面的代码不能直接用rows
                        var newRows = $(this).data('rows');
                        if (newRows) {
                            //延迟刷新状态
                            for (var i = 0; i < newRows.length; i++) {
                                if (flowid == newRows[i].FLOWID) {
                                    var status = newRows[i].LAUNCH_STATE;
                                    setTimeout(function () {
                                        if (status == 'STARTING') {
                                            setTimeout(function () {
                                                that.grid.jqGrid().trigger("reloadGrid");
                                            }, 3000);
                                        } else {
                                        }
                                    }, 3000);
                                }
                            }
                        }
                    }
                });
                if (datas.rows.length > 0) {
                    $(".tempo-message").css("display", "none");
                    $('#jobContainer').find('.ui-paging-info').show()
                } else {
                    $('#jobContainer').find('.ui-paging-info').hide();
                    $(".tempo-message").css("display", "");
                    if (nowstatus == "isrunning") {
                        $(".tempo-message").children().html("暂无数据");
                    } else if (nowstatus == "starting") {
                        $(".tempo-message").children().html("暂无数据");
                    } else if (nowstatus == "unstart") {
                        $(".tempo-message").children().html("暂无数据");
                    } else {
                        $(".tempo-message").children().html("暂无数据,请在设计区进行流程发布");
                    }
                }
                var browser = $.support.clearCloneStyle;
                var screenWidth = screen.width;
                if (browser) {
                    $this.find("input.tempo-checkbox+label").css("font-size", "12px");
                } else {
                    if (screenWidth == 1366) {
                        //解决IE11下复选框过大问题
                        $this.find("input.tempo-checkbox+label").css("font-size", "10px");
                    }
                }
                //判断浏览器是否为ie浏览器
                if ((TempoUtils.isIE()) && screenWidth == 1366) {
                    //解决IE11下复选框过大问题
                    $this.find("input.tempo-checkbox+label").css("font-size", "10px");
                }
            },
            beforeRequest: function () {
                var current_page = $(this).getGridParam("page");//获取返回的当前页
                var total_page = $(this).getGridParam("lastpage");//获取总页数
                var cont_page = allDatas.length / $(this).getGridParam("rowNum") + 1;
                if (total_page != 0 && current_page > cont_page) {
                    that.grid.datagrid("reloadGridToLastPage", {}, true, true, total_page);
                }
            },
        });
        //解决1366分辨率下ie11下表格显示一条黑线问题
        $this.find(".ui-jqgrid-hdiv").css("height", "38px");
        if (navigator.userAgent.indexOf("Firefox") >= 0) {
            $this.find(".ui-jqgrid-hdiv").css("border-bottom", "0px solid #eee");
        } else {
            $this.find(".ui-jqgrid-hdiv").css("border-bottom", "1px solid #eee");
        }
    }
    //筛选框位置计算
    var sxtop = $("#shaix").offset().top;
    var sxleft = $("#shaix").offset().left;
    console.log("横坐标" + sxtop);
    $("#shaixuanDiv").css("top", sxtop + 30);
    $("#shaixuanDiv").css("left", sxleft - 360);
    var updatestaticsInfo = function (rows) {
        failedCount = 0;
        successCount = 0;
        var waiteCount = 0;
        var awaitCount = 0;
        var pauseCount = 0;
        var completeCount = 0;
        if (rows && rows.length > 0) {
            for (var i = 0; i < rows.length; i++) {
                var jobInfo = rows[i];
                var trigger = jobInfo.trigger;
                if (trigger) {
                    if ("PAUSED" == trigger.status || "PAUSED_BLOCKED" == trigger.status) {
                        pauseCount++;
                    } else if ("COMPLETE" == trigger.status) {
                        completeCount++;
                    } else if ("AWAIT" == trigger.status) {
                        awaitCount++;
                    } else {
                        waiteCount++;
                    }
                }
                failedCount += jobInfo.failedCount;
                successCount += jobInfo.successCount;
            }
        }
        allCount = rows.length;
        $this.find(".tempo-task-complete").val("全部" + rows.length);
        var startSucceedCountArr = [];
        var startSucceedCount = 0;
        var unstart = 0;
        var starting = 0;
        var iftrue = " ";
        for (i = 0; i < rows.length; i++) {
            iftrue = rows[i].LAUNCH_STATE;
            if (iftrue == "RUNNING") {
                startSucceedCountArr.push(iftrue);
            } else if (iftrue == "STARTING") {
                starting++;
            } else {
                unstart++;
            }
        }
        startSucceedCount = startSucceedCountArr.length;
        $this.find(".tempo-task-startSucceed").val("已启动" + startSucceedCount);
        $this.find(".tempo-task-unstart").val("未启动" + unstart);
        $this.find("#tempo-asyn-starting").val("启动中" + starting);
        $this.find(".state_succ_bt").attr("disabled", true);
        $this.find(".state_fail_bt").attr("disabled", true);
        $this.find(".tempo-task-succeed").attr("disabled", true);
        $this.find(".tempo-task-failed").attr("disabled", true);
    }

    /**
     * 渲染表格数据和事件
     * @param isReloadGrid 是否重新加载表格
     */
    var initRefresh = function (isReloadGrid) {
        if ($this.find('.view-container').height() - 98 > 0) {
            $this.find('.publish_tab').height($this.find('.view-container').height() - 98)
        }
        if (isReloadGrid != false) {
            initJobGrid();
        }
        $(".ui-paging-info").hide();
        if (isReloadGrid !== false) {
            that.grid.jqGrid().trigger("reloadGrid");
        }
        var form = $this.find('.queryJobSchedulingForm').css("display", "block");
        if (allDatas.length == 0) {
            $(".tempo-message").css("display", "");
        } else {
            $(".tempo-message").css("display", "none");
        }

        TempoUtils.parserUi(form, {});
        form.find('[name="starttime"]').datepicker({
            dateFormat: "yy-mm-dd",
            yearRange: "c-100:",
            //设置日期的最大时间和最小时间
            minDate: DateUtils.formatDate(new Date(new Date().getFullYear() - 100, 0, 1)),
            maxDate: DateUtils.formatDate(new Date(new Date().getFullYear() + 1, 0, 1)),
            changeYear: true,
            changeMonth: true,
            onClose: function (selectedDate) {
                var d = $(this).datepicker('getDate');
                if (d == null) {
                    form.find('[name="endtime"]').datepicker("option", "minDate", null);
                    return;
                }
                var d2 = new Date(d.getTime());
                var d2str = d2.Format('yyyy-MM-dd');
                form.find('[name="endtime"]').datepicker("option", "minDate", d2str);
            },
            onSelect: function (value) {
            },
            onChangeMonthYear: function (year, month, inst) {
                var month = inst.selectedMonth + 1;
                var day = inst.selectedDay;
                var format = function (v) {
                    return String(v).length > 1 ? v : ('0' + v)
                }
                $(this).val(inst.selectedYear + '-' + format(month) + '-' + format(inst.selectedDay));
                $.datepicker._hideDatepicker(this);
            }
        }).css("width", "100px");
        form.find('[name="endtime"]').datepicker({
            dateFormat: "yy-mm-dd",
            yearRange: "c-100:",
            //设置日期的最大时间和最小时间
            minDate: DateUtils.formatDate(new Date(new Date().getFullYear() - 100, 0, 1)),
            maxDate: DateUtils.formatDate(new Date(new Date().getFullYear() + 1, 0, 1)),
            changeYear: true,
            changeMonth: true,
            onSelect: function (value) {
            },
            onClose: function (selectedDate) {
                var d = $(this).datepicker('getDate');
                if (d == null) {
                    form.find('[name="starttime"]').datepicker("option", "maxDate", null);
                    return;
                }
                var d2 = new Date(d.getTime());
                var d2str = d2.Format('yyyy-MM-dd');
                form.find('[name="starttime"]').datepicker("option", "maxDate", d2str);
            },
            onChangeMonthYear: function (year, month, inst) {
                var month = inst.selectedMonth + 1;
                var day = inst.selectedDay;
                var format = function (v) {
                    return String(v).length > 1 ? v : ('0' + v)
                }
                $(this).val(inst.selectedYear + '-' + format(month) + '-' + format(inst.selectedDay));
                $.datepicker._hideDatepicker(this);
            }
        }).css("width", "100px");
        //判断当前日期输入框里是否有值，如没值就将蓝点隐藏
        var if_to_hide = function () {
            //获取筛选div里的搜索input框
            var inputs = $('#shaixuanDiv').find('input');
            //定义是否有数据标识 true表示有数据
            var hasValue = false;
            for (var i = 0; i < inputs.length; i++) {
                if (inputs.eq(i).val().trim() != "") {
                    hasValue = true;
                    break;
                }
            }
            //如果搜索框中有值，则显示图标
            if (hasValue) {
                $("#ifshaixuan").removeAttr('style');
                $(".sizer-reset").css("color", "#5185e4")
            } else {
                $("#ifshaixuan").hide();
            }
        }
        form.find('[name="laststarttime"]').datepicker({
            dateFormat: "yy-mm-dd",
            yearRange: "c-100:",
            //设置日期的最大时间和最小时间
            minDate: DateUtils.formatDate(new Date(new Date().getFullYear() - 100, 0, 1)),
            maxDate: DateUtils.formatDate(new Date(new Date().getFullYear() + 1, 0, 1)),
            changeYear: true,
            changeMonth: true,
            onClose: function (selectedDate) {
                var d = $(this).datepicker('getDate');
                if (d == null) {
                    form.find('[name="lastendtime"]').datepicker("option", "minDate", null);
                    return;
                }
                var d2 = new Date(d.getTime());
                var d2str = d2.Format('yyyy-MM-dd');
                form.find('[name="lastendtime"]').datepicker("option", "minDate", d2str);
            },
            onSelect: function (value) {
                if_to_hide();
            },
            onChangeMonthYear: function (year, month, inst) {
                var month = inst.selectedMonth + 1;
                var day = inst.selectedDay;
                var format = function (v) {
                    return String(v).length > 1 ? v : ('0' + v)
                }
                $(this).val(inst.selectedYear + '-' + format(month) + '-' + format(inst.selectedDay));
                if_to_hide();
            }
        }).css("width", "100px");
        form.find('[name="lastendtime"]').datepicker({
            dateFormat: "yy-mm-dd",
            yearRange: "c-100:",
            //设置日期的最大时间和最小时间
            minDate: DateUtils.formatDate(new Date(new Date().getFullYear() - 100, 0, 1)),
            maxDate: DateUtils.formatDate(new Date(new Date().getFullYear() + 1, 0, 1)),
            changeYear: true,
            changeMonth: true,
            onSelect: function (value) {
                if_to_hide();
            },
            onClose: function (selectedDate) {
                var d = $(this).datepicker('getDate');
                if (d == null) {
                    form.find('[name="laststarttime"]').datepicker("option", "maxDate", null);
                    return;
                }
                var d2 = new Date(d.getTime());
                var d2str = d2.Format('yyyy-MM-dd');
                form.find('[name="laststarttime"]').datepicker("option", "maxDate", d2str);
            },
            onChangeMonthYear: function (year, month, inst) {
                var month = inst.selectedMonth + 1;
                var day = inst.selectedDay;
                var format = function (v) {
                    return String(v).length > 1 ? v : ('0' + v)
                }
                $(this).val(inst.selectedYear + '-' + format(month) + '-' + format(inst.selectedDay));
                if_to_hide();
            }
        }).css("width", "100px");

        form.find('[name="createStartTime"]').datepicker(
            {
                dateFormat: "yy-mm-dd",
                yearRange: "c-100:",
                // 设置日期的最大时间和最小时间
                minDate: DateUtils.formatDate(new Date(new Date()
                    .getFullYear() - 100, 0, 1)),
                maxDate: DateUtils.formatDate(new Date(new Date()
                    .getFullYear() + 1, 0, 1)),
                changeYear: true,
                changeMonth: true,
                width: 50,
                onClose: function (selectedDate) {
                    var d = $(this).datepicker('getDate');
                    if (d == null) {
                        form.find('[name="createEndTime"]').datepicker(
                            "option", "minDate", null);
                        return;
                    }
                    var d2 = new Date(d.getTime());
                    var d2str = d2.Format('yyyy-MM-dd');
                    form.find('[name="createEndTime"]').datepicker(
                        "option", "minDate", d2str);
                },
                onChangeMonthYear: function (year, month, inst) {
                    var month = inst.selectedMonth + 1;
                    var day = inst.selectedDay;
                    var format = function (v) {
                        return String(v).length > 1 ? v : ('0' + v)
                    }
                    $(this).val(
                        inst.selectedYear + '-' + format(month) + '-'
                        + format(inst.selectedDay));
                    $.datepicker._hideDatepicker(this);
                }
            }).css("width", "100px");
        form.find('[name="createEndTime"]').datepicker(
            {
                dateFormat: "yy-mm-dd",
                yearRange: "c-100:",
                // 设置日期的最大时间和最小时间
                minDate: DateUtils.formatDate(new Date(new Date()
                    .getFullYear() - 100, 0, 1)),
                maxDate: DateUtils.formatDate(new Date(new Date()
                    .getFullYear() + 1, 0, 1)),
                changeYear: true,
                changeMonth: true,
                onSelect: function (value) {
                },
                onClose: function (selectedDate) {
                    var d = $(this).datepicker('getDate');
                    if (d == null) {
                        form.find('[name="createStartTime"]').datepicker(
                            "option", "maxDate", null);
                        return;
                    }
                    var d2 = new Date(d.getTime());
                    var d2str = d2.Format('yyyy-MM-dd');
                    form.find('[name="createStartTime"]').datepicker(
                        "option", "maxDate", d2str);
                },
                onChangeMonthYear: function (year, month, inst) {
                    var month = inst.selectedMonth + 1;
                    var day = inst.selectedDay;
                    var format = function (v) {
                        return String(v).length > 1 ? v : ('0' + v)
                    }
                    $(this).val(
                        inst.selectedYear + '-' + format(month) + '-'
                        + format(inst.selectedDay));
                    $.datepicker._hideDatepicker(this);
                }
            }).css("width", "100px");

        $('.queryBtn').button({
            emphasize: true,
        }).css("width", "60px");
        form.find('.resetBtn').button({
            emphasize: true,
            click: function () {
                form[0].reset();
                form.find('[name="endtime"]').datepicker("option", "minDate", DateUtils.formatDate(new Date(new Date().getFullYear() - 100, 0, 1)));
                form.find('[name="starttime"]').datepicker("option", "maxDate", DateUtils.formatDate(new Date(new Date().getFullYear() + 1, 0, 1)));
                form.find('[name="lastendtime"]').datepicker("option", "minDate", DateUtils.formatDate(new Date(new Date().getFullYear() - 100, 0, 1)));
                form.find('[name="laststarttime"]').datepicker("option", "maxDate", DateUtils.formatDate(new Date(new Date().getFullYear() + 1, 0, 1)));
                form.find('[name="createEndTime"]').datepicker("option", "minDate", DateUtils.formatDate(new Date(new Date().getFullYear() - 100, 0, 1)));
                form.find('[name="createStartTime"]').datepicker("option", "maxDate", DateUtils.formatDate(new Date(new Date().getFullYear() + 1, 0, 1)));
                form.find('[name="jobstatus"]').val('').selectmenu('refresh');
                form.find('[name="jobname"]').val('');
                form.find('[name="jobcreator"]').val('')
                form.find('[name="workspaceName"]').val('');
                form.find('[name="applicationName"]').val('');
                return false;
            }
        }).css("width", "60px");
    }

    var openViewDetailDialog = function (job) {
        var paramDialog = $('<div style="width:100%;height:100%;"/></div>').attr("id", 'app-flow-scheduling-execute-detail');
        var parentDiv = $this.find("#jobContainer");
        paramDialog.dialog({
            title: "服务详情",
            width: $this.width(),
            height: $this.height(),
            resizable: false,
            modal: true,
            close: function () {
                paramDialog.dialog('destroy');
            },
            open: function () {
                $m.loadPage(contextPath + "/api/ai/app/statistics/service_view", $(this), job.SERVICEID, {"data": job});
                $(".ui-dialog-title").before("<span class='ui-icon tempo-ui-icon tempo-ui-icon-leftarrows-undertint tempo-leftback' style='float: left;margin-top: 12px;'></span>")
                $("#app-flow-scheduling-execute-detail").prev().find("button").css("display", "none")
                $(".ui-draggable-handle").css("cursor", "auto");
                $(".tempo-leftback").css("cursor", "pointer");
                $(".tempo-leftback").click(function () {
                    //清除成果管理页面服务状态刷新定时器
                    clearInterval(window.manageLoopUpdateTimer);
                    paramDialog.dialog('destroy');
                    $(".after_select").hide();
                    nowSizerStatus();
                    setTimeout(function () {
                        for (var i = 0; i < 3; i++) {
                            that.grid.setGridParam({loadui: false}).trigger("reloadGrid");
                        }
                    }, 2000);
                });
            }
        });
    }
    //初始化表格
    initRefresh();
    //初始化成果管理页面页面变动监听事件
    var timeout = 0;
    window.addEventListener('resize', function () {
        if (timeout != 0) {
            clearTimeout(timeout);
        }
        timeout = setTimeout(function () {
            that.grid.datagrid("reloadGrid");
            //调整弹框宽度
            if ($this.find("#app-flow-scheduling-execute-detail").length > 0) {
                $this.find("#app-flow-scheduling-execute-detail").parent().css("width", $this.width());
                if ($this.find("#app-flow-scheduling-execute-detail").find(".tempo-head-li").length > 0) {
                    var tempoHeadLis = $this.find("#app-flow-scheduling-execute-detail").find(".tempo-head-li");
                    for (var i = 0; i < tempoHeadLis.length; i++) {
                        var $tempoHeadLi = $(tempoHeadLis[i]);
                        if ($tempoHeadLi.css("border-bottom") == '2px solid rgb(31, 115, 182)') {
                            //触发选中页签的点击事件，重新触发页面样式
                            $tempoHeadLi.trigger("click");
                            break;
                        }
                    }
                }
            }
            timeout = 0;
        }, 200)
    });
    //增加定时刷新列表机制，每5秒刷新一次
    var myStreamInterval = setInterval(function () {
        //批量选择不显示才进行刷新
        if ($(".after_select").is(":hidden")) {
            initRefresh();
        }
    }, 5000);
    window.myStreamInterval = myStreamInterval;
});